﻿declare var mvcModel: any;

module WorkBasket.Dash {
    var SOC = WorkBasket.SOC;
    WorkbasketApp.controller('wbDashCTRL',
        function ($scope) {
            var SOC = WorkBasket.SOC;
            $scope.NewInvitations = mvcModel.NewInvitations;

            $scope.Accept = function (Invite:WorkBasket.Entities.Invite, Accepted) {
                Invite.Accepted = Accepted;
                Invite.Responded = new Date().toJSON();
                SOC.Invites().SaveData(Invite);
                if (Accepted) {
                    var gm = new WorkBasket.Entities.Groupmember(0, Invite.GroupID, Invite.UserID);
                    SOC.GroupMembers().SaveData(gm);
                    
                }
                $scope.NewInvitations = SOC.Invites().GetData("GetReceivedInvitesByCurrentUserID", null);

                

            }



        });
    }